package com.gemcoder.system.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Map;
import javax.annotation.Resource;
import com.gemcoder.system.bo.Result;
import com.gemcoder.system.service.FaultlistService;
import cn.hutool.core.util.StrUtil;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;

@Controller
@RequestMapping("/Faultlist")
public class FaultlistController {

    @Resource
    private FaultlistService FaultlistService;

    @RequestMapping(value = "/createFaultReport")
    @ResponseBody
    public Result createFaultReport(@RequestBody(required = false) Map<String, Object> paramMap) {
        // 校验设备名称
        if (paramMap.get("EquipmentNamevalue1") == null || String.valueOf(paramMap.get("EquipmentNamevalue1")).isEmpty()) {
            return new Result(false, "设备名称必填!", null);
        }
        // 校验故障类别
        if (paramMap.get("FaultCategory1value1") == null || String.valueOf(paramMap.get("FaultCategory1value1")).isEmpty()) {
            return new Result(false, "故障类别必填!", null);
        }
        // 校验是否影响开机
        if (paramMap.get("Whetherthestartupisaffectedvalue1") == null || String.valueOf(paramMap.get("Whetherthestartupisaffectedvalue1")).isEmpty()) {
            return new Result(false, "是否影响开机必填!", null);
        }
        // 校验当前状态
        if (paramMap.get("CurrentStatusvalue1") == null || String.valueOf(paramMap.get("CurrentStatusvalue1")).isEmpty()) {
            return new Result(false, "当前状态必填!", null);
        }
        // 调用service层的代码
        return FaultlistService.createFaultReport(paramMap);
    }

    @RequestMapping(value = "/searchFaultReports")
    @ResponseBody
    public Result searchFaultReports(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return FaultlistService.searchFaultReports(paramMap);
    }

    @RequestMapping(value = "/exportFaultReports")
    @ResponseBody
    public Result exportFaultReports(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return FaultlistService.exportFaultReports(paramMap);
    }

    @RequestMapping(value = "/getFaultReports")
    @ResponseBody
    public Result getFaultReports(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return FaultlistService.searchFaultReports(paramMap);
    }

    @RequestMapping(value = "/getCurrentUser")
    @ResponseBody
    public Result getCurrentUser(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return FaultlistService.getCurrentUser(paramMap);
    }

    @RequestMapping(value = "/getCurrentTime")
    @ResponseBody
    public Result getCurrentTime(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return FaultlistService.getCurrentTime(paramMap);
    }
}
